package cn.edu.yzu.scholarship.validator;

import cn.edu.yzu.scholarship.constant.C;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class LoginValidator extends Validator {

	@Override
	protected void validate(Controller c) {
		this.validateInteger("userType", C.UT_STUDENT, C.UT_SYSTEM, "errorInfo", "用户类型不正确！");
		this.validateRequired("loginName", "errorInfo", "请输入用户名！");
		this.validateRequired("loginPwd", "errorInfo", "请输入密码！");
	}

	@Override
	protected void handleError(Controller c) {
		c.renderJson("errorInfo",c.getAttr("errorInfo"));
	}

}
